﻿using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;

namespace MapleLeaf.Client.Pages {

    public partial class RecordPage : Page {

        public readonly RecordPageViewModel Context;
        public RecordPage() {

            DataContext = Context = new RecordPageViewModel();
            InitializeComponent();
        }

        /// <summary>
        /// 上一页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PrevPage_Click(object sender, RoutedEventArgs e) {
            if (Context.PageIndex > 1) {
                RecordPageViewModel context = Context;
                int pageIndex = context.PageIndex;
                context.PageIndex = pageIndex - 1;
            }
        }

        /// <summary>
        /// 下一页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NextPage_Click(object sender, RoutedEventArgs e) {
            if (Context.PageIndex < Context.PageLength) {
                RecordPageViewModel context = Context;
                int pageIndex = context.PageIndex;
                context.PageIndex = pageIndex + 1;
            }
        }

        /// <summary>
        /// 第一页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FirstPage_Click(object sender, RoutedEventArgs e) {
            Context.PageIndex = 1;
        }
        /// <summary>
        /// 最后一页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LastPage_Click(object sender, RoutedEventArgs e) {
            Context.PageIndex = Context.PageLength;
        }


    }
}
